import React, { Component } from 'react'
import { Link, Route } from 'react-router-dom';
import Detail from './detail';
export default class Message extends Component {
  state = {
    messageList: [
      {
        id: 0,
        title: "消息1"
      },
      {
        id: 1,
        title: "消息2"
      },
      {
        id: 2,
        title: "消息3"
      }
    ]
  }
  render() {
    const { messageList } = this.state
    return (
      <div>
        {
          messageList.map(e => {
            return <div key={e.id}>
              {/* 携带参数 */}
              <Link to={`/home/message/detail/${e.id}/${e.title}`}>{e.title}</Link>
            </div>
          })
        }
        {/* 声明参数 */}
        <Route path="/home/message/detail/:id/:title" component={Detail} />
      </div>
    )
  }
}
